# -- coding: utf-8 --
from selenium.webdriver.common.by import By
import time

if __name__ == '__main__':

    from selenium import webdriver
    driver = webdriver.Firefox()
    driver.implicitly_wait(5)
    driver.maximize_window()
    driver.get('http://192.168.44.128:8080/WoniuSales/')

    driver.find_element(By.ID, 'username').send_keys('admin')
    driver.find_element(By.ID, 'password').send_keys('123456')
    driver.find_element(By.ID, 'verifycode').send_keys('0000')
    driver.find_element(By.CSS_SELECTOR, 'button.form-control').click()

    driver.get('http://192.168.44.128:8080/WoniuSales/goods')
    driver.find_element(By.ID, 'batchname').send_keys('GB20230225')
    driver.find_element(By.ID, 'batchfile').send_keys(r'G:\temp\b13.xls')
    driver.find_element(By.CSS_SELECTOR, 'form.form-inline:nth-child(2) > div:nth-child(1) > input:nth-child(1)').click()

    driver.get('http://192.168.44.128:8080/WoniuSales/store')
    driver.find_element(By.ID, 'goodsserial').send_keys('ME900065')
    driver.find_element(By.ID, 'barcode').click()
    driver.find_element(By.ID, 'barcode').send_keys('456345634')
    driver.find_element(By.ID, 'inputsize').send_keys('70')
    driver.find_element(By.ID, 'quantity').send_keys('80')
    driver.find_element(By.CSS_SELECTOR, 'input.btn-primary').click()
    driver.switch_to.alert.accept()

    driver.get('http://192.168.44.128:8080/WoniuSales/sell')
    driver.find_element(By.ID, 'barcode').send_keys('11111111')
    driver.find_element(By.CSS_SELECTOR, 'div.container:nth-child(6) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > form:nth-child(1) > button:nth-child(3)').click()
    driver.find_element(By.ID, 'submit').click()
    driver.switch_to.alert.accept()
    time.sleep(3)
    driver.switch_to.alert.accept()
    driver.close()